# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/8/26
# @File : TPM（step3）B. Total Length（CF）.py


def TPM():
    l = 0
    sum = 0
    res = 0
    for r in range(n):
        sum += rate[r]
        while (sum > s):
            sum -= rate[l]
            l += 1
        res += (r - l + 1)*(r - l + 2)/2#求1加到n的公式，
    return res

"""
step2 第三题的模板，这次不是求区间个数，是求全部区间长度的和：sum of lengths of all good segments.
"""
if __name__ == "__main__":
    n, s = map(int, input().split())
    rate = [int(i) for i in input().split()]
    print(int(TPM()))